﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

namespace PaintDotNet.Web.Data
{
    public class util
    {
        public util()
        {
        
        }
        public static string getUserImage(string user, string imageId ,imageType type, bool exitsProve)
        {
            string _dir;

            switch (type)
            {
                case imageType.temporary:
                    _dir = ConfigurationManager.AppSettings["PNETDirTemp"] + user + "\\" + imageId;
                    if (exitsProve)
                    { 
                        if (!File.Exists(_dir))
                        {
                            _dir = ConfigurationManager.AppSettings["PNETDirMain"] + "NOTAVAILABLE";
                        }
                    }
                    return _dir;
                case imageType.permanent:
                    _dir = ConfigurationManager.AppSettings["PNETDirPerm"] + user + "\\" + imageId;
                    return _dir;
                default:
                    goto case imageType.temporary;
            }
        }

        public static imageType convertIntToImageType(int type)
        {
            switch (type)
            {
                case 0:
                    return imageType.temporary;
                case 1:
                    return imageType.permanent;
                default:
                    goto case 0;
            }
        }
    }
    public enum imageType
    {
        temporary = 0,
        permanent = 1
    }
}
